Page({
  onLoad ({ id }) {
    // 获取通行证
    this.getPassport(id)
  },
  async getPassport (id) {
    if (!id) return
    const { code, data: passport } = await wx.http.get('/visitor/' + id)
    if (code !== 10000) return wx.utils.toast('获取通行证失败!')
    // 渲染数据
    this.setData({
      ...passport
    })
  },
  onShareAppMessage () {
    return {
      title: '你爱来不来',
      path: '/visitor_pkg/pages/passport/index',
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
  async saveImage () {
    // 1. 获取图片的临时路径
    const res = await wx.getImageInfo({ src: this.data.url })
    console.log('res', res)
    // 2. 存图片到本地
    wx.saveImageToPhotosAlbum({ filePath: res.path })
  }
})
